<%--
  Created by IntelliJ IDEA.
  User: wyl
  Date: 2021-12-28
  Time: 18:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.validate.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/js/messages_zh.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/login.css">
</head>
<body>
<h1>Erpsystem</h1>
<div class="login-app">
    <!-- 选择登录方式部分 -->
    <div class="login-header" onclick="checkRadio()">
        <input type="radio" name="login-opt" id="message" checked="checked">
        <label for="message" class="m-btn">账号登录</label>
        <input type="radio" name="login-opt" id="username">
        <label for="username" class="u-btn">短信登录</label>
        <input type="radio" name="login-opt" id="qrcode">
        <label for="qrcode" class="q-btn">扫码登录</label>
    </div>
    <!-- 登录表单部分 -->
    <div class="login-body">
        <div id="form-bar">
            <!-- <form-append></form-append> -->
            <!-- 账号登录表单 -->
            <form id="myform">
                <input type="text" id="userName" placeholder="请输入账号">
                <input type="password" id="pass" placeholder="请输入密码">
                <input type="submit" id="btn01" class="login-btn" value="登录">
            </form>
            <!-- 短信登录表单 -->
            <form action="" class="m-form">
                <input type="text" placeholder="请输入手机号码">
                <input type="text" placeholder="请输入验证码"><button class="vercode-btn">获取验证码</button>
                <input type="checkbox" name="" id="sure">
                <label for="sure" class="tobesure"><p>未注册手机登录时会自动创建新账号，我已阅读并同意<a href="">服务协议</a>和<a href="">隐私权条款</a></p></label>
                <button class="login-btn">登录</button>
            </form>
            <!-- 扫码登录表单 -->
            <form action="" class="q-form">
                <div class="qrcode">
                    <img src="image/2.jpg" alt="图片不存在">
                </div>
            </form>
        </div>
    </div>
</div>
<script src="js/script.js"></script>
<script>
     $("#btn01").click(function () {
         var param01= {
             messages: {
                 userName: {
                     "required": "请输入用户名",
                     "minlength": "最少输入4位"
                 },

                 uname: {
                     "required": "请输入用户名",
                     "minlength": "用户名不能少于4位"
                 }
             },
             submitHandler: function (form) {
                 var param02 = {
                    url:"${pageContext.request.contextPath}/login.action",
                    data:{loginId:$("#userName").val(),password:$("#pass").val()},
                    dataType:'json',
                     success:function (data) {
                            if (data!=0){
                                location.href="${pageContext.request.contextPath}/index.jsp";
                            }else {
                                alert("账号或密码输入错误")
                            }
                         }
                 }
                 $("#myform").ajaxSubmit(param02)
             }
         }
         $("#myform").validate(param01)
    })
</script>
</body>
</html>
